package br.ufpe.cin.camid.sample;

import java.io.Serializable;

import br.ufpe.cin.camid.core.objects.ManagedObject;

@ManagedObject
public class ConcreteCalculator implements Serializable, Calculator {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -231551801087073711L;

	/* (non-Javadoc)
	 * @see br.ufpe.cin.camid.sample.Calculator#sum(Double, Double)
	 */
	@Override
	public Double sum(Double a, Double b)
	{
		return a + b;
	}
	
	/* (non-Javadoc)
	 * @see br.ufpe.cin.camid.sample.Calculator#sub(Double, Double)
	 */
	@Override
	public Double sub(Double a, Double b)
	{
		return a - b;
	}
	
	/* (non-Javadoc)
	 * @see br.ufpe.cin.camid.sample.Calculator#multi(Double, Double)
	 */
	@Override
	public Double multi(Double a, Double b)
	{
		return a * b;
	}
	
	/* (non-Javadoc)
	 * @see br.ufpe.cin.camid.sample.Calculator#div(Double, Double)
	 */
	@Override
	public Double div( Double a, Double b )
	{
		if( b.doubleValue() == 0 )
			throw new ArithmeticException("Denominator is equal to 0");
		return a / b;
	}

}
